package com.ruoyi.web.controller.comlbs;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.LatLng;
import com.ruoyi.common.core.domain.tree.TreeHelper;
import com.ruoyi.system.domain.request.electricFence.PoiCitySearchParam;
import com.ruoyi.system.service.CommonService;
import com.ruoyi.system.service.IProvincesService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 描述 通用下拉菜单Controller
 * 作者 ZhangPing
 * 创建时间 2023/8/17 17:10
 */
@RestController
@RequestMapping("/comlbs/search")
public class SearchController extends BaseController {

    @Autowired
    private IProvincesService provincesService;
    @Autowired
    private CommonService commonService;

    @ApiOperation("省市区树")
    @GetMapping("/provincesTree")
    public AjaxResult provincesTree() {
        return success(TreeHelper.buildTree(provincesService.list()));
    }

    @ApiOperation("根据经纬度获取位置信息(高德)")
    @PostMapping("/getMinAdsByPoi")
    public AjaxResult getMinAdsByPoi(@RequestBody LatLng param) {
        return success((Object) commonService.latLngToAddress(param));
    }

    @ApiOperation("根据经纬度获取位置信息(84)")
    @PostMapping("/getMinAdsBy84Poi")
    public AjaxResult getMinAdsBy84Poi(@RequestBody LatLng param) {
        return success((Object) commonService.latLngToAddress84(param));
    }

    @ApiOperation("位置查询")
    @PostMapping("/matchQuery")
    public AjaxResult matchQuery(@RequestBody PoiCitySearchParam param) {
        return success(commonService.matchQuery(param));
    }
}
